home *** CD-ROM | disk | FTP | other *** search
- From: alindbac@sw.seisy.abb.se (Anders Lindback)
- Message-ID: <4km1qj$bpu@sdaw04.seinf.abb.se>
- X-Original-Date: 12 Apr 1996 16:53:39 GMT
- Path: in2.uu.net!bounce-back
- Date: 14 Apr 96 12:35:30 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Initialization of references.
- Organization: ABB Industrial Systems AB, Vdsteres, Sweden
- Reply-To: alindbac@sw.seisy.abb.se
- Summary: then is a reference initialized correctly
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMXDxNOEDnX0m9pzZAQE4UwF+LoFN22mv63OKmxyJIfdeGznMc8+8RD6J
- sYW9exrHNovCQbGISKIfGFSZ/1tWXJHM
- =Xjd1
-
- The september 95 Working draft 8.3.1 says:
-
- "A reference shall be initialized to refer to a valid object or function."
-
- What is a valid object ? I can't find a good decription of that in
- the draft. Is it:
-
- 1. An object that has storage.
- 2. An object which constructor has executed.
- 3. A typo ?
- 4. An out-of-date sentence in the draft.
- 5. None of the above ?
-
- Example code from gnu.g++.help:
-
- >#include <iostream.h>
- >
- >class Foo
- >{
- >public:
- > Foo (int size_arg = 0) : size (my_size), my_size (size_arg),
- > values (new double [size]) {}>
- ~Foo () { delete values; }
- > int const& size;
- >private:
- > int my_size;
- > double* values;
- >};
-
- Is this code correct C++ code or not ?
-
- Or must one change the order of the member variables in the
- class so that my_size is before size and get to be intialized
- first ?
-
- And what will happend if they not are integers but actuall classes
- with constructors ?
-
- Anders
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-